/********************************************************************************
 * Project Name		[JavaEE_Web]
 * File Name     	[MaxTag.java]
 * Creation Date 	[2015-01-01]
 * 
 * Copyright© ge.y.yang@gmail.com All Rights Reserved
 * 
 * Work hard, play harder, think big and keep fit
 ********************************************************************************/
package jsp.tag;

import java.io.IOException;

import javax.servlet.jsp.JspException;
import javax.servlet.jsp.JspWriter;
import javax.servlet.jsp.tagext.SimpleTagSupport;

/**
 * 一个简单的tag[继承了SimpeTagSupport类], 实现了获得两个数字中较大的一个的功能
 * 
 * @author 不落的太阳(Sean Yang aka ShortPeace)
 * @version 1.0
 * @since jdk 1.8
 * 
 */
public class MaxTag extends SimpleTagSupport {

	private String number1;
	private String number2;

	public void setNumber1(String number1) {
		this.number1 = number1;
	}

	public void setNumber2(String number2) {
		this.number2 = number2;
	}

	@Override
	public void doTag() throws JspException, IOException {
		JspWriter out = this.getJspContext().getOut();
		Integer num1 = Integer.parseInt(number1);
		Integer num2 = Integer.parseInt(number2);
		out.print(num1 > num2 ? num1 : num2);
	}
}
